package com.lufei4.chestnut.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.lifecycle.Lifecycle;

import com.lufei4.chestnut.R;
import com.lufei4.chestnut.network.BaseActivity;
import com.lufei4.chestnut.view.helper.MyLifeCycleObserver;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @ProjectName: Chestnut
 * @Package: com.lufei4.chestnut.view
 * @ClassName: ThreadActivity
 * @Description: java类作用描述
 * @Author: liushijiang 15833013864@163.com
 * @CreateDate: 2021/1/14 16:02
 * @UpdateUser: 更新者：
 * @UpdateDate: 2021/1/14 16:02
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */

public class ThreadActivity extends BaseActivity {
    @BindView(R.id.btn_1)
    Button btn1;
    @BindView(R.id.btn_2)
    Button btn2;
    @BindView(R.id.btn_3)
    Button btn3;
    private MyLifeCycleObserver observer;

    @Override
    public int getLayoutId() {
        return R.layout.activity_thread;
    }

    @Override
    public void initView() {
        observer =new MyLifeCycleObserver();
        getLifecycle().addObserver(observer);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.btn_1, R.id.btn_2, R.id.btn_3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_1:
                startActivity(new Intent(this, MainActivity3.class));
                break;
            case R.id.btn_2:
                if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
                    // do something After Started
                }
                break;
            case R.id.btn_3:
                break;
        }
    }
}
